package com.sctvcloud.bazhong.ui.utils;

import android.app.Activity;
import android.content.Context;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by Administrator on 2017/7/26 0026.
 */

public class MyWindowUtils {
    public static void changeWindowAlpha(Context context, float alpha){
        Window window = ((Activity) context).getWindow();
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.alpha = alpha;
        window.setAttributes(layoutParams);
    }

    public static void changeWindowBright(Context context, float screenBrightness){
        Window window = ((Activity) context).getWindow();
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.screenBrightness = screenBrightness;
        window.setAttributes(layoutParams);
    }

    public static float getCurrentBright(Context context){
        Window window = ((Activity) context).getWindow();
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        return layoutParams.screenBrightness;
    }
}
